<link href="../addons/jy_jdpm/resource/css/mobile/lib/amazeui.min.css" rel="stylesheet" type="text/css">
<link href="../addons/jy_jdpm/resource/css/mobile/base.css" rel="stylesheet" type="text/css">
<link href="../addons/jy_jdpm/resource/css/mobile/search-result.css" rel="stylesheet" type="text/css" onload="$('#loadhtml').show()">
    <script>
        (function (doc, win) {
            var docEl = doc.documentElement,
                // 手机旋转事件,大部分手机浏览器都支持 onorientationchange 如果不支持，可以使用原始的 resize
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    //clientWidth: 获取对象可见内容的宽度，不包括滚动条，不包括边框
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
                };

            recalc();
            //判断是否支持监听事件 ，不支持则停止
            if (!doc.addEventListener) return;
            //注册翻转事件
            win.addEventListener(resizeEvt, recalc, false);

        })(document, window);

        function showTime(tuanid, time_distance) {
            this.tuanid = tuanid;
            //PHP时间是秒，JS时间是微秒
            this.time_distance = time_distance * 1000 - new Date().getTime();
        }
    </script>
    <style>
        .classify {
            width: 100%;
            height: 25px;
            line-height: 25px;
            font-size: 14px;
            background-color: #d7d7d7;
            margin: 5px 0;
        }

        .classify a {
            width: 33.33%;
            height: 25px;
            display: block;
            float: left;
            text-align: center;
            color: #0b0b0b;
        }

        .classify a.opt {
            color: darkred;
        }
        #nontList{
            width: 100%;
            height: 50px;
            display: block;
            text-align: center;
            padding: 15px;
            color: #7f7f7f;
        }
    </style>
<div id="loadhtml" style="display:none">
<section class="search-box">
    <div class="search-con index_search_btn">
        <img src="../addons/jy_jdpm/resource/images/mobile/icon-search.png" ng-click="access(pagedata.op,made_query(pagedata.params))" alt="" class="icon-search">
        <input type="search" class="search-input disabled" ng-model="pagedata.params.keyword" placeholder="想寻找什么内容呢？搜搜看">
    </div>
</section>
<section class="search-result">
    <div class="classify">
        <a ng-class="{'opt':pagedata.status==0}" href="javascript:;" ng-click="getlist(0,pagedata.cid);pagedata.status=0">即将开始</a>
        <a ng-class="{'opt':pagedata.status==1}" href="javascript:;" ng-click="getlist(1,pagedata.cid);pagedata.status=1">正在拍卖</a>
        <a ng-class="{'opt':pagedata.status==2}" href="javascript:;" ng-click="getlist(2,pagedata.cid);pagedata.status=2">已经结束</a>
    </div>
    <ul class="search-result-list">
        <a id="goodslist" ng-repeat="v in pagedata.goods" href="javascript:;" ng-click="access_json('jy_jdpm/detail/','pid='+v.pid)">
            <li class="search-result-item">
                <div class="img-box">
                    <img src="{{tomedia(v.images)}}" alt="">
                    <p class="baozhenjin">保证金：{{v.bzprice || '0.00'}}元</p>
                </div>
                <div class="goods-info">
                    <div>
                        <div class="goods-name">{{v.pname}}</div>
                        <div class="count">竞价次数：
                            <span class="color-red">{{v.count || 0}}</span>
                        </div>
                        <div class="current-price" style="padding-left: 2px;">当&nbsp;前&nbsp;竞&nbsp;价：
                            <span class="color-red number">¥{{v.bidding}}</span>
                        </div>
                        <div class="current-price">当前成交价：
                            <span class="color-red number">¥{{v.clinch}}</span>
                        </div>
                        <div class="current-price" style="padding-left: 1px;">&nbsp;&nbsp;起&nbsp;&nbsp;拍&nbsp;&nbsp;价&nbsp;：
                            <span class="color-red number">¥{{v.onset}}</span>
                        </div>
                    </div>
                    <div>
                        <div class="status">
                           
                                <span ng-if="v.status ==0" class="text">未开始</span><span class="times" times="{{v.start}}"></span>
                         
                                <span ng-if="v.status ==1" class="text">拍卖中</span><span class="times" times="{{v.end}}"></span>
   
                                <span ng-if="v.status ==2" class="text" style="background-color: #CCC;">已结束</span><span>{{v.end}}</span>
                            
                        </div>
                    </div>
                </div>
            </li>
        </a>
    </ul>
    <p id="nontList">{{pagedata.goods.length <1 ? '没有更多了..' : '下拉获取更多..'}}</p>
</section>
<div ng-include="sys_html('common/w_footer')"></div>
</div>
<script>
scope.loading = true;  //状态标记
//滚动加载
scope.scroll(function(){
	scope.loading = true;  //状态标记
	scope.$apply();
	setTimeout('getlist()',2000);
},false,'svposttext');
var page = 2;
scope.getlist = function(status,cid){
		var cid =cid?cid:scope.pagedata.cid;
		var params = {
					'plugin':'jy_jdpm',
					'action':'goodslist',
					'op':'main',
					'query':{
						'page':page,
						'status':status,
						'cid':cid
					},
					'callback':function(data){
					console.log(data);
							if(data.error !=1){
							 for (var i=0;i<data.goods.length;i++){
									scope.pagedata.goods.push(data.goods[i]);
								}
								if(page >1){
									$("#goodslist").animate({scrollTop:0},300);
								}
								page++;
								scope.loading = false;
								scope.$apply();
							}else{
								onsole.log('error');
							};
					}
		}
		scope.post_json(params);
}
    function getMyDate(now) {
        var testDate = new Date(parseInt(now) * 1000);//必须为整数型的毫秒数
        return testDate.format("yyyy-MM-dd hh:mm:ss");
    }

    /**
     * 将数值四舍五入(保留2位小数)后格式化成金额形式
     * @param num 数值(Number或者String)
     * @return 金额格式的字符串,如'1,234,567.45'
     * @type String
     */
    function formatCurrency(num) {
        num = num.toString().replace(/\$|\,/g, '');
        if (isNaN(num))
            num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 100 + 0.50000000001);
        cents = num % 100;
        num = Math.floor(num / 100).toString();
        if (cents < 10)
            cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
            num = num.substring(0, num.length - (4 * i + 3)) + ',' +
                num.substring(num.length - (4 * i + 3));
        return (((sign) ? '' : '-') + num + '.' + cents);
    }
</script>
</div>